import { authProvider } from '@boticord/auth'
import { BotClientModule } from '@boticord/bot-client'
import { StartupModule } from '@boticord/startup'
import { Module } from '@nestjs/common'
import { ConfigModule, ConfigService } from '@nestjs/config'
import { AuthController } from './controllers/auth.controller'
import { BadgeController } from './controllers/badge.controller'
import { UsersController } from './controllers/users.controller'
import { UsersService } from './services/users.service'
import { RpcController } from './controllers/rpc.controller'
import { rpcProvider } from '@boticord/auth/guard/rpc.guard'

@Module({
  imports: [
    StartupModule.forRoot('UsersService'),
    BotClientModule.forRootAsync({
      imports: [ ConfigModule ],
      inject: [ ConfigService ],
      useFactory: (cfg: ConfigService) => {
        return {
          natsServers: cfg.getOrThrow<string>('NATS_SERVERS').split(','),
        }
      },
    }),
  ],
  controllers: [ AuthController, UsersController, BadgeController, RpcController ],
  providers: [
    authProvider,
    rpcProvider,
    UsersService,
  ],
})
export class AppModule {}
